
<?php
//模块插件类
//对外接口函数类，其他插件可通过“$this->plugin('jy_jdapi')->方法名” 来调用本类的方法
defined('BY_JYA') or exit('error');
class func_jy_jdapi extends plugin{
	/****商品上架和下架****/
	public function upOrDown($wareid,$wareid,$optype){ 
		$setting=$this->get_setting();
		$access_token=$setting['access_token'];
		$appKey=$setting['appKey'];
		$appSecret=$setting['appSecret'];
	
		$c = new JdClient();
		$c->appKey = appKey;
		$c->appSecret = appSecret;
		$c->accessToken = accessToken;
		$c->serverUrl = SERVER_URL;

		$req = new WareWriteUpOrDownRequest();

		$req->setAppId( "jingdong" );
		$req->setName( "jingdong" );
		$req->setNote($note);
		$req->setWareId($wareid);
		$req->setOpType($optype);

		$resp = $c->execute($req, $c->accessToken);
		return $resp;
			
	}
	/****修改商品名称****/
	public function updateWareTitle($wareid,$title){ 
		$setting=$this->get_setting();
		$access_token=$setting['access_token'];
		$appKey=$setting['appKey'];
		$appSecret=$setting['appSecret'];
	
		$c = new JdClient();
		$c->appKey = appKey;
		$c->appSecret = appSecret;
		$c->accessToken = accessToken;
		$c->serverUrl = SERVER_URL;

		$req = new WareWriteUpdateWareTitleRequest();

		$req->setAppId( "jingdong" );
		$req->setName( "jingdong" );
		$req->setWareId($wareid);
		$req->setTitle($title);

		$resp = $c->execute($req, $c->accessToken);

		return $resp;
			
	}
	/****删除商品****/
	public function updateWare($wareid){ 
		$setting=$this->get_setting();
		$access_token=$setting['access_token'];
		$appKey=$setting['appKey'];
		$appSecret=$setting['appSecret'];
	
		$c = new JdClient();
		$c->appKey = $appKey;
		$c->appSecret = $appSecret;
		$c->accessToken = $access_token;
		$c->serverUrl = SERVER_URL;

		$req = new WareWriteDeleteRequest();

		$req->setAppId( "jingdong" );
		$req->setName("jingdong");
		$req->setWareId($wareid);

		$resp = $c->execute($req, $c->accessToken);
		return $resp;
	
	}	
	/****恢复删除的商品****/
	public function updateWare($wareid){ 
		$setting=$this->get_setting();
		$access_token=$setting['access_token'];
		$appKey=$setting['appKey'];
		$appSecret=$setting['appSecret'];
	
		$c = new JdClient();
		$c->appKey = $appKey;
		$c->appSecret = $appSecret;
		$c->accessToken = $access_token;
		$c->serverUrl = SERVER_URL;

		$req = new WareWriteRecoverWareRequest();

		$req->setAppId( "jingdong" ); $req->setName( "jingdong" ); $req->setWareId($wareid);

		$resp = $c->execute($req, $c->accessToken);
		return $resp;
	
	}

	}
}
include("JdSdk.php");
?>
